package qf.com.dao.impl;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import qf.com.dao.UserDao;
import qf.com.domain.Profile;
import qf.com.domain.User;
import qf.com.utils.DButils;

import java.sql.SQLException;

public class Userdao implements UserDao {
    private QueryRunner queryRunner = new QueryRunner();
    int update = 0;
    public int jiayonghu(String yonghuming, String mima){
            String sql = "INSERT INTO `bbb`(`username`,`password`,`status`)VALUES (?,?,1)";
            try {
                update = queryRunner.update(DButils.getConnection(), sql, yonghuming, mima);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        System.out.println(update);
            return update;

    }

    public Profile chazaho(String yonghuming){
        String sql = "SELECT * FROM aaa WHERE name= ?";
        Profile query=null;
        try {
            query = queryRunner.query(DButils.getConnection(), sql, new BeanHandler<>(Profile.class), yonghuming);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        System.out.println(update);
        return query;

    }

}
